//:C05:FriendScope.cpp
#include <iostream>
using namespace std;

class Friendly
{
    int i;
    public:
        Friendly(int theInt)
        {
            i = theInt;
        }
        friend void f(const Friendly&);    // Needs global def.
        void g()
        {
            f(*this);
        }
};

void h()
{
    f(Friendly(1));    // Uses ADL
}

void f(const Friendly& fo)
{
    // Definition of friend
    cout << fo.i << endl;
}

int main(void)
{
    h();    // Prints 1
    Friendly(2).g();    // Prints 2
}
